﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using SmoLiteApi.Helper;

namespace SmoLiteApi
{
    /// <summary/>
    public class DatabaseExtendedProperty
    {
        private Database _database;
        private string _name;
        private object _value;

        /// <summary/>
        public DatabaseExtendedProperty(
            Database database,
            string name)
        {
            this._database = database;
            this._name = name;
        }

        /// <summary/>
        public void Create()
        {
            using (SqlCommandHelper sqlCommandHelper = SqlCommandHelper.FetchProcedureCommand(this._database.SqlConnection, Constant.PROCEDURE_ADD_EXTENDED_PROPERTY))
            {
                // set inputs
                sqlCommandHelper.Parameters.Add(new SqlParameter(Constant.PARAMETER_NAME, this._name));
                sqlCommandHelper.Parameters.Add(new SqlParameter(Constant.PARAMETER_VALUE, this._value));

                // run the command
                sqlCommandHelper.ExecuteNonQuery();
            }
        }

        /// <summary/>
        public string Name
        {
            get { return this._name; }
            set { this._name = value; }
        }

        /// <summary/>
        public object Value
        {
            get { return this._value; }
            set { this._value = value; }
        }
    }
}
